package com.wsl.HealthChallenge.controllers;

import com.wsl.HealthChallenge.utils.HashCodeUtil;

public class ValueAndDate {
    public final long collectionDate;
    public final int value;
    private int fHashCode = 0;

    public ValueAndDate(long collectionDate, int value) {
        this.collectionDate = collectionDate;
        this.value = value;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ValueAndDate) {
            ValueAndDate other = (ValueAndDate) obj;
            return (value == other.value) && (collectionDate == other.collectionDate);
        }
        return super.equals(obj);
    }

    @Override public int hashCode() {
        if ( fHashCode == 0) {
          int result = HashCodeUtil.SEED;
          result = HashCodeUtil.hash( result, value);
          result = HashCodeUtil.hash( result, collectionDate);
          fHashCode = result;
        }
        return fHashCode;
      }
}